package cn.hesion.designpattern.StrategyPattern.Pay.payPort;

public class Order {
    private String uId;
    private String orderId;
    private double amount;

    public Order(String uId, String orderId, double amount) {
        this.uId = uId;
        this.orderId = orderId;
        this.amount = amount;
    }

    //完美解决Switch和ifelse
    public PayState Pay(){
        return Pay(PayStrategy.DEFAULT_PAY);
    }

    public PayState Pay(String payKey) {
        PayMent payMent = PayStrategy.get(payKey);
        System.out.println("欢迎使用"+payMent.getName());
        System.out.println("本次交易金额为"+amount+",开始扣款");
        return payMent.pay(uId,amount);
    }
}
